package com.haiwen;

class MThread implements Runnable{

    @Override
    public void run() {
        label:for (int i = 2; i < 100; i++) {
            for(int j = 2;j < Math.sqrt(i);j++){
                if(i%2==0){
                    System.out.println(Thread.currentThread().getName()+"质数为："+i);
                    continue label;
                }
            }
        }
    }
}
public class ThreadTest1 {
    public static void main(String[] args) {
        MThread mThread = new MThread();

        Thread thread = new Thread(mThread);

        thread.setName("线程1");

        thread.start();
        //再启动一个线程，遍历100以内的偶数
        Thread t2 = new Thread(mThread);
        t2.setName("线程2");
        t2.start();
    }
}
